package org.xa3apm.vote.hibernate.bean;

import java.io.Serializable;
import java.util.Collection;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import org.xa3apm.vote.hibernate.entities.Province;

@Stateless
public class ProvinceBean implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = -1552824271777944656L;
	@PersistenceContext(unitName = "vote")
	private EntityManager em;

	public Province getById(Long id) {
		return (Province) (em.createNamedQuery("Province.getById")
				.setParameter("Id", id).getSingleResult());
	}

	public Collection<Province> getAll() {
		@SuppressWarnings("unchecked")
		Collection<Province> resultList = em
				.createNamedQuery("Province.getAll").getResultList();
		return resultList;
	}

}
